﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ZHDJ.MobileInterface
{
    public partial class WxLdzdCreateMassesVoice : AbstractBasePage
    {
        protected override OutParam BusinessProcess<InParam, OutParam>(InParam inParam)
        {
            // 业务逻辑返回的响应对象  
            WxLdzdCreateMassesVoiceOutParam result = new WxLdzdCreateMassesVoiceOutParam();
            WxLdzdCreateMassesVoiceInParam param = new WxLdzdCreateMassesVoiceInParam();
            string logMsg = "";
            bool isFlag = true;

            try
            {
                param = inParam as WxLdzdCreateMassesVoiceInParam;
                if (string.IsNullOrEmpty(param.item_id))
                {
                    result.code = "0";
                    result.desc = "社区/村公司ID不能为空";

                    isFlag = false;
                }

                else if (string.IsNullOrEmpty(param.login_id))
                {
                    result.code = "0";
                    result.desc = "提交用户ID不能为空";

                    isFlag = false;
                }
                else if (string.IsNullOrEmpty(param.mobileno))
                {
                    result.code = "0";
                    result.desc = "联系方式不能为空";

                    isFlag = false;
                }
                else if (string.IsNullOrEmpty(param.title))
                {
                    result.code = "0";
                    result.desc = "主题不能为空";

                    isFlag = false;
                }
                else if (string.IsNullOrEmpty(param.content))
                {
                    result.code = "0";
                    result.desc = "反映内容不能为空";

                    isFlag = false;
                }
                else if (!InterfaceHelper.LdzdCheckItemID(param.item_id))
                {
                    result.code = "0";
                    result.desc = "社区/村公司ID不存在";

                    isFlag = false;
                } 
                if (isFlag)
                {
                    isFlag = InterfaceHelper.CheckLoginIDCountEx(param.login_id);

                    if (!isFlag)
                    {
                        result.code = "0";
                        result.desc = "用户不存在";
                    }


                }

                if (isFlag)
                {
                    if (!InterfaceHelper.LdzdCreateMassesVoice(param.item_id,
                                                              param.login_id,
                                                              param.mobileno,
                                                              param.title,
                                                              param.content))
                    {
                        result.code = "0";
                        result.desc = "操作异常，多次出现请联系管理员";
                    }
                }


                

                logMsg = result.desc;
            }
            catch (Exception ex)
            {
                result.code = "0";
                result.desc = "操作异常，多次出现请联系管理员";
                logMsg = ex.Message + ":" + ex.StackTrace;
            }
            //result.desc = logMsg;
            CommonUtils.InsertMobileInterfaceLog(SystemCode + "-UserWxLdzdCreateMassesVoice", SerializeHelper.JsonSerializer<WxLdzdCreateMassesVoiceInParam>(param), logMsg);
            return result as OutParam;
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (string.Compare(Request.QueryString["Safe"], "False", true) == 0)
                ProcessRequest<WxLdzdCreateMassesVoiceInParam, WxLdzdCreateMassesVoiceOutParam>();
            else
                SafeProcessRequest<WxLdzdCreateMassesVoiceInParam, WxLdzdCreateMassesVoiceOutParam>();
        }
    }
    //{"item_id":"","login_id":"","mobileno":"","title":"","content":""}
    public class WxLdzdCreateMassesVoiceInParam
    {
        /// <summary>
        ///	社区/村公司ID
        /// </summary>
        public string item_id
        { get; set; }

        /// <summary>
        ///	提交用户id
        /// </summary>
        public string login_id
        { get; set; }

        /// <summary>
        ///	联系方式 
        /// </summary>
        public string mobileno
        { get; set; }

        /// <summary>
        ///	主题
        /// </summary>
        public string title
        { get; set; }

        /// <summary>
        ///	反映内容：
        /// </summary>
        public string content
        { get; set; }
    }

    public class WxLdzdCreateMassesVoiceOutParam
    {
        public WxLdzdCreateMassesVoiceOutParam()
        {
            code = "1";
            desc = "操作成功";
        }

        public string code
        { get; set; }

        public string desc
        { get; set; }
    }
}